\name{dlmm_bugs}
\alias{dlmm_bugs}
\title{Dynamic Linear Mixed Models via Bugs}
\usage{
  dlmm_bugs(formula,
    family = c("gaussian", "bernoulli", "binomial", "poisson"),
    data, inits = NULL, parameters.to.save = NULL, weights,
    offset, subset, na.action = NULL, contrasts = NULL,
    n.chains = 3, model.file = "model.bug", do.fit = TRUE,
    working.directory = NULL, save.ranef = FALSE, ...)
}
\arguments{
  \item{formula}{a two-sided linear formula object
  describing the model structure, with the response on the
  left of a ~ operator and the terms, separated by +
  operators, on the right. The syntax is similar to that
  used by \code{\link[lme4]{lmer}}, where the vertical bar
  character "|" separates an expression for a model matrix
  and a grouping factor for random effects. In addition,
  the double vertical bar "||" is used to separate an
  expression for a model matrix and a grouping factor for
  dynamic effects. Either fixed effects or random effects,
  or both can be missing. However, dynamic effects must be
  present.}

  \item{family}{a string in \code{c("gaussian",
  "bernoulli", "binomial", "poisson")} that specifies the
  distribution of the observation.}

  \item{data}{an optional data frame containing the
  variables named in \code{formula}. By default the
  variables are taken from the environment from which the
  function is called.}

  \item{inits}{an optional list of initial values to be
  used for each chain.  It must be of length
  \code{n.chains}. Each element is a named list with names
  correponding to the random nodes used in Bugs. If not
  supplied, the function will generate initial values
  automatically.}

  \item{parameters.to.save}{an optional character vector of
  the names of the parameters to save.}

  \item{weights}{an optional vector of weights to be used.}

  \item{offset}{this can be used to specify an a priori
  known component to be included in the linear predictor.}

  \item{subset}{an optional vector specifying a subset of
  observations to be used in the creating the model frame.}

  \item{na.action}{a function which indicates what should
  happen when the data contain \code{NA}s. The default is
  \code{NULL}, where no action is taken. This is important
  when the \code{NA}s are used in the response to indicate
  cells to be predicted by Bugs, or to flag cells that are
  truncated or censored.}

  \item{contrasts}{an optional list. See
  \code{\link[stats]{lm}}.}

  \item{n.chains}{number of Markov chains (default: 3).}

  \item{model.file}{a string that specifies the name of the
  file storing the model script written by the function.
  This file is further used by
  \code{\link[R2WinBUGS]{bugs}}. The default name is
  \code{"model.bug"}.}

  \item{do.fit}{a logical scalar. When \code{FALSE} the
  model is not fit but instead a structure with the data,
  initial values and parameter names is returned, which can
  be modified for special model forms and passed onto
  \code{bugs}.}

  \item{working.directory}{sets working directory during
  execution of this function.  See
  \code{\link[R2WinBUGS]{bugs}}.}

  \item{save.ranef}{a logical scalar indicating whether
  random effects will be saved.  The default is
  \code{FALSE}. This is helpful when there is a large
  number of random effects that require considerable amount
  of memory.}

  \item{...}{arguments passed to \code{bugs}.}
}
\description{
  This function fits dynamic linear mixed models in Bugs.
}
\keyword{models}

